home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000099_icon-group-sender _Tue Apr 1 13:38:29 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: by cheltenham.cs.arizona.edu; Tue, 1 Apr 1997 16:42:30 MST
Message-Id: <334101C5.6EED@charlie.cns.iit.edu>
Date: Tue, 01 Apr 1997 13:38:29 +0100
From: "Thomas W. Christopher" <tc@charlie.cns.iit.edu>
Reply-To: tc@charlie.cns.iit.edu
Organization: Illinois Institute of Technology
X-Mailer: Mozilla 3.01Gold (WinNT; I)
Mime-Version: 1.0
To: Norman Ramsey <nr@viper.cs.Virginia.EDU>
Cc: icon-group@cs.arizona.edu
Subject: Re: file locking in unix Icon
References: <5hps5g$5kg@viper.cs.Virginia.EDU>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1166
Norman Ramsey wrote:
>
> I need an Icon program to maintain a database of received messages.
> Because these messages come in the mail, multiple copies of the
> program can be running at one time. I'd like to lock the database.
> The Unix flock() primitive provides a readers/writers locking
> capability, which is just what I need, but I'm not sure how to import
> it into Icon. (I figure it can be done using the dynamic loading
> capability, which I don't understand.)
>
> Does anybody out there have C code that will implement Icon functions
> to acquire and release locks on the file descriptors underlying Icon
> files?
The usual UNIX trick is to use an empty file to be a lock. If the
file exists, it means the lock is set. If it doesn't exist, it means
unlocked.
You execute a UNIX "creat" for the file. If the file exists (and you are
not superuser) the creation will fail.
If, however, the file does not exist, the creation will be successful.
Close and remove the file to unlock.
I'm guessing this will work in Icon with open(lockfilename,"c").
--
-Thomas W. Christopher http://www.iit.edu/~tc
tc@charlie.cns.iit.edu